<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>PicBed admin</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script src="../js/common.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>

<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form" lay-filter="sys-setting">
                <input type="hidden" name="id" value="">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label"> 网站关键词 </label>
                    <div class="layui-input-block">
                        <textarea placeholder="网站关键词，多个用逗号(英文)隔开" class="layui-textarea" rows="3" cols="20" style="width: 45%; height: 5%;" name="key_words"></textarea>
                    </div>
                </div>
                <!-- <div class="layui-form-item">
                    <label for="key_words" class="layui-form-label"> 网站关键字 </label>
                    <div class="layui-input-inline">
                        <input type="text" id="key_words" name="key_words" required="" lay-verify="key_words"
                            autocomplete="on" class="layui-input">
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label for="user_upload_size" class="layui-form-label">
                        用户上传单张图片大小
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="user_upload_size" name="user_upload_size" lay-verify="user_upload_size"
                            autocomplete="on" class="layui-input" placeholder="单位：字节">
                    </div>
                    <!-- <div class="layui-form-mid layui-word-aux">
                          <span class="x-red">*</span>
                      </div> -->
                </div>
                <div class="layui-form-item">
                    <label for="user_upload_number" class="layui-form-label">
                        用户每次上传图片数量
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="user_upload_number" name="user_upload_number" required=""
                            lay-verify="user_upload_number" autocomplete="on" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="guest_upload_size" class="layui-form-label">
                        游客上传单张图片大小
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="guest_upload_size" name="guest_upload_size"
                            lay-verify="guest_upload_size" autocomplete="on" class="layui-input" placeholder="单位：字节">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="guest_upload_number" class="layui-form-label">
                        游客每次上传图片数量
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="guest_upload_number" name="guest_upload_number" required=""
                            lay-verify="guest_upload_number" autocomplete="on" class="layui-input">
                    </div>
                </div>
                <!-- <div class="layui-form-item" id="push-bus">

                    <label for="user_upload_number" class="layui-form-label">
                        <span class="x-red">*</span>厂商账号
                    </label>
                    <div class="layui-input-inline">
                        <select name="bid" lay-filter="select-push-bus" id="select-push-bus">
                            <option value="0">-- 请选择信息推送地区 --</option>
                        <option value="1">全部厂商</option>
                        <option value="2">特定地区厂商</option>
                        </select>
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">
                    </label>
                    <button class="layui-btn" lay-filter="setting" lay-submit="">
                        设置
                    </button>
                </div>
            </form>
        </div>
    </div>
    <script>
        layui.use(['form', 'layer'],
            function () {
                $ = layui.jquery;
                var form = layui.form,
                    layer = layui.layer;

                /* 渲染厂商账号 */
                $.ajax({
                    url: window.config.api_url + '/sysconfig',
                    method: 'get',
                    data: {},
                    dataType: 'json',
                    processData: true,
                    cache: false,
                    async: false,
                    headers: {
                        token: window.config.token,
                        rtime: window.func.getTime()
                    },
                    success: function (res) {
                        if (res.code == 0) {
                            var data = res.data;
                            form.val('sys-setting', {
                                id: data.id,
                                key_words: data.key_words,
                                user_upload_size: data.user_upload_size,
                                user_upload_number: data.user_upload_number,
                                guest_upload_size: data.guest_upload_size,
                                guest_upload_number: data.guest_upload_number
                            });
                        } else {
                            layer.msg(res.msg, { time: 1000, icon: 2 });
                        }
                    },
                    error: function () {
                        window.func.error();
                    }
                });

                //监听提交
                form.on('submit(setting)', function (data) {
                    // console.log(data);
                    //发异步，把数据提交给php
                    $.ajax({
                        url: window.config.api_url + '/sysset',
                        method: 'post',
                        data: data.field,
                        dataType: 'json',
                        processData: true,
                        cache: false,
                        headers: {
                            token: window.config.token,
                            rtime: window.func.getTime()
                        },
                        success: function (res) {
                            if (res.code == 0) {
                                layer.msg("修改成功", {
                                    icon: 6,
                                    time: 1000
                                });
                                setTimeout(function () {
                                    //关闭当前frame
                                    xadmin.close();
                                    // 可以对父窗口进行刷新 
                                    xadmin.father_reload();
                                }, 1000);
                            } else {
                                layer.msg(res.msg, {
                                    icon: 2,
                                    time: 1000
                                });
                            }

                        },
                        error: function () {
                            window.func.error();
                        }
                    });

                    return false;
                });
            });
    </script>
</body>

</html>